<?php
// 应用公共文件
use think\facade\Cache;

function setCache ($key, $value, $expire = 0)
{
    $host = $_SERVER['HTTP_HOST'];
    $key .= $host;

    $tag = 'railyway_system_';
    return Cache::tag($tag)->set($key,$value,$expire);
}
function delCache ($key)
{
    $host = $_SERVER['HTTP_HOST'];
    $key .= $host;
    return Cache::delete($key);
}
function getCache ($key)
{
    if ( !hasCache($key) ) return false;

    $host = $_SERVER['HTTP_HOST'];
    $key.= $host;
    return Cache::get($key);
}

function hasCache ($key)
{
    $host = $_SERVER['HTTP_HOST'];
    $key .= $host;

    return Cache::has( $key );
}

function clearCache ($tag_data = '')
{
    $tag = 'railway_' . $tag_data;

    return Cache::tag($tag)->clear();
}
